

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<!-- <script src="https://unpkg.com/axios/dist/axios.min.js"></script> -->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<body>
  <button id="btnAdd">发送增请求 使用post请求</button>
  <button id="btnDelete">发送删请求 delete</button>
  <button id="btnUpDate">发送改请求 put</button>
  <button id="btnGet">发送查请求 get</button>
</body>

<script>

  let oBtnAdd =document.querySelector(`#btnAdd`)
  oBtnAdd.onclick= async function(){

    const re = await axios.post("/add",{

      name:"xiaoA",age:18,sex:"男"},{})
    
    console.log(re.data,"add");
  }

  let oBtnDelete =document.querySelector(`#btnDelete`)
  oBtnDelete.onclick= async function(){

    const re = await axios.delete("/delete",{})
    
    console.log(re.data,"delete");
  }

  let oBtnUpdate =document.querySelector(`#btnUpDate`)
  oBtnUpdate.onclick= async function(){

    const re = await axios.put("/update", {
        name:"xiaoA",
        age: 18,
        sex: "男 "
      })
    
    console.log(re.data,"update");
  }
  
  let oBtnGet =document.querySelector(`#btnGet`)
  oBtnGet.onclick= async function(){

    const re = await axios.get("/get",{})
    
    console.log(re.data,"get");
  }


</script>
</html>